<!DOCTYPE html>
<html lang="en">

<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/css/common.css">
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">

<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">所有书籍</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingOne">
                            <h4 class="panel-title">
                                <a role="button" data-toggle="collapse" data-parent="#accordion"
                                   href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                    搜索栏
                                </a>
                            </h4>
                        </div>
                        <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel"
                             aria-labelledby="headingOne">
                            <div class="panel-body">
                                <form action="{:U('Index')}" class="form-horizontal" method="get">

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">一级分类</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="region_one" value="{$CSDATA.region_one}">
                                                <option value="">请选择</option>
                                                <foreach name="type_one" item="v" key="k">
                                                    <option value="{$v.region_one}">{$v.region_one}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                        <label class="col-sm-2 control-label">二级分类</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="region_two">
                                                <option value="">请选择</option>
                                                <foreach name="type_two" item="v" key="k">
                                                    <option value="{$v.region_two}">{$v.region_two}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">名称</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="TITLE" value="{$CSDATA.TITLE}">
                                        </div>
                                        <label class="col-sm-2 control-label">条形码</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="ISBN" value="{$CSDATA.ISBN}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">作者</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="AUTHOR" value="{$CSDATA.AUTHOR}">
                                        </div>
                                        <label class="col-sm-2 control-label">出版社</label>

                                        <div class="col-sm-4">
                                            <input class="form-control" name="PRESS" value="{$CSDATA.PRESS}">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">入库</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="STATE">
                                                <option value="">请选择</option>
                                                <option value="入库">入库</option>
                                                <option value="未入库">未入库</option>
                                            </select>
                                        </div>
                                        <label class="col-sm-2 control-label">是否上架</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="SXJ">
                                                <if condition="$CSDATA.SXJ == -1"> <option style="color: red" value="{$CSDATA.SXJ}">下架</option></if>
                                                <if condition="$CSDATA.SXJ == 1"> <option style="color: red" value="{$CSDATA.SXJ}">上架</option></if>
                                                <option value="">请选择</option>
                                                <option value="1">上架</option>
                                                <option value="-1">下架</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">书籍包装</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="PACKING_SPECIFICATION">
                                                <option value="">请选择</option>
                                                <foreach name="BOOK_BZ" item="v" key="k">
                                                    <option value="{$v.region_name}">{$v.region_name}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                        <label class="col-sm-2 control-label">适读年龄段</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="AGE">
                                                <option value="">请选择</option>
                                                <foreach name="BOOK_AGE" item="v" key="k">
                                                    <option value="{$v.region_name}">{$v.region_name}</option>
                                                </foreach>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">可能有误书籍颜色</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="RED">
                                                <option value="">请选择</option>
                                                <option style="color: red" value="1">书名重复</option>
                                                <option style="color: blue" value="2">ISBN重复</option>
                                                <option style="color: indigo" value="3">ISBN为空</option>
                                            </select>
                                        </div>
                                        <label class="col-sm-2 control-label">是否黑名单</label>

                                        <div class="col-sm-4">
                                            <select class="form-control" name="IS_BLACK">
                                                <if condition="$CSDATA.IS_BLACK == -1"> <option style="color: red" value="{$CSDATA.IS_BLACK}">白名单</option></if>
                                                <if condition="$CSDATA.IS_BLACK == 1"> <option style="color: red" value="{$CSDATA.IS_BLACK}">黑名单</option></if>
                                                <option value="">请选择</option>
                                                <option value="-1">白名单</option>
                                                <option value="1">黑名单</option>
                                            </select>
                                        </div>
                                    </div>
                                    <input class="form-control" type="hidden" name="SGCODE" value="{$SGCODE}">
                                    <input class="form-control" type="hidden" name="SS" value="{$SS}">
                                    <input class="form-control" type="hidden" name="banner_id" value="{$banner_id}">
                                    <input class="form-control" type="hidden" name="TZ" value="{$TZ}">
                                    <input class="form-control" type="hidden" name="BY" value="{$BY}">

                                    <div class="form-group">
                                        <div class="col-sm-10 col-sm-offset-2">
                                            <button type="submit" class="btn  btn-primary">筛选</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="row">
                    <div class="panel-body">
                        <div class="dataTable_wrapper">
                            <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <include file="Extends/searchForUser"/>
                                <thead>
                                <tr style="color: #008200;color-interpolation: red;align-content: center">
                                    <th width="8px" style="text-align:center"><input name="all_checkbox" type='checkbox'
                                                                                     id="all_checkbox"></th>
                                    <th style="text-align:center" width="50px" class="text-center GridSortTh"
                                        data-order="ID">编码
                                    </th>
                                    <th style="text-align:center" width="125px" class="text-center GridSortTh"
                                        data-order="ISBN">条形码
                                    </th>
                                    <th style="text-align:center" width="180px" class="text-center GridSortTh"
                                        data-order="TITLE">书名
                                    </th>
                                    <th style="text-align:center" width="60px" class="text-center GridSortTh"
                                        data-order="AUTHOR">作者
                                    </th>
                                    <th style="text-align:center" width="100px" class="text-center GridSortTh"
                                        data-order="PRESS">出版社
                                    </th>
                                    <!--<th style="text-align:center" id="list3">上下架</th>-->
                                    <!--<th style="text-align:center">库存</th>-->
                                    <th style="text-align:center" class="text-center GridSortTh"
                                        data-order="PACKING_SPECIFICATION">包装
                                    </th>
                                    <!--<th style="text-align:center" id="list6">入库</th>-->
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="AGE">年龄
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="PIC_URL">
                                        图片
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="STOCK">库存
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="Y_PRICE">
                                        定价
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="XS_PRICE">
                                        售价
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="HS_PRICE">
                                        回收价
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="LOOK_NUM">
                                        阅读量
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="SCORE">
                                        评分
                                    </th>
                                    <th class="text-center GridSortTh" data-order="SORT">排序</th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="SXJ">
                                        上下架
                                    </th>
                                    <th style="text-align:center" width="10%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="DATA" item="v">
                                    <if condition="$v.IS_BLACK == 1">
                                        <tr style="color: silver">
                                            <else/>
                                        <tr>
                                    </if>
                                    <td><input type='checkbox' name='checkbox'></td>
                                    <td>{$v.ID}</td>
                                    <td>{$v.ISBN}</td>
                                    <td>{$v.TITLE}</td>
                                    <td>{$v.AUTHOR}</td>
                                    <td>{$v.PRESS}</td>
                                    <!--<td>{$v.SXJ}</td>-->
                                    <td>{$v.PACKING_SPECIFICATION}</td>
                                    <!--<td>{$v.STATE}</td>-->
                                    <td>{$v.AGE}</td>
                                    <td><img width="80px" src="{$v.PIC_URL}"></td>
                                    <td>{$v.STOCK}</td>
                                    <td>{$v.Y_PRICE}</td>
                                    <td>{$v.XS_PRICE}</td>
                                    <td>{$v.HS_PRICE}</td>
                                    <td>{$v.LOOK_NUM}</td>
                                    <td>{$v.SCORE}</td>
                                    <td  onclick="add('{$v.ID}' ,$(this))" >{$v.SORT}</td>

                                    <td>
                                        <if condition="$v.SXJ == 0">
                                            <span class="btn btn-danger btn-xs"
                                                  onclick="updateShelves('{$v.ID}' ,$(this))">下架中</span>
                                            <else/>
                                            <span class="btn btn-warning btn-xs"
                                                  onclick="updateShelves('{$v.ID}' ,$(this))">上架中</span>
                                        </if>
                                    </td>
                                    <if condition="$v.ID gt 0">
                                    <td>
                                        <a target='_blank' href="{:U('EditBookIndex')}?ID={$v.ID}"><span
                                                class="btn btn-warning btn-xs">编辑/查看</span></a>
                                        <span onclick='showcz($(this))'>更多</span><br/>

                                        <div hidden>
                                            <button class='btn btn-danger btn-xs' onclick="del('{$v.ID}',$(this))">删除
                                            </button>
                                            <if condition="$v.IS_BLACK == 0">
                                                <button class="btn btn-warning btn-xs"
                                                        onclick="AddBlackBook('{$v.ID}',$(this),1)">加入黑名单
                                                </button>
                                                <else/>
                                                <br/>
                                                <button class="btn btn-warning btn-xs"
                                                        onclick="AddBlackBook('{$v.ID}',$(this)),0">洗白
                                                </button>
                                            </if>
                                            <if condition="$SGCODE">
                                                <button class="btn btn-warning btn-xs"
                                                        onclick="RuKu('{$v.ID}',$(this))">导入书柜
                                                </button>
                                            </if>
                                            <if condition="$banner_id">
                                                <button class="btn btn-warning btn-xs"
                                                        onclick="BookList('{$v.ID}',$(this))">导入书单
                                                </button>
                                            </if>
                                            <if condition="$SS">
                                                <button class="btn btn-warning btn-xs"
                                                        onclick="AddSBook('{$v.ID}',$(this))">添加收书书籍
                                                </button>
                                            </if>
                                            <if condition="$TZ">
                                                <button class="btn btn-warning btn-xs"
                                                        onclick="AddTzBook('{$v.ID}',$(this))">属于套装书
                                                </button>
                                            </if>
                                            <if condition="$BY">
                                                <button class="btn btn-warning btn-xs"
                                                        onclick="AddByBook('{$v.ID}',$(this))">是否包邮
                                                </button>
                                            </if>
                                        </div>
                                    </td>
                                        <else/>
                                        <td>
                                             <a class="btn btn-warning btn-xs"
                                                href="{:U('DRbook')}?id={$v.booklistid}">导入</a>
                                        </td>
                                    </if>
                                    </tr>
                                </foreach>
                                </tbody>
                            </table>
                            <div class="blue">{$show}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--副本-->
    <div id="allayModal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
         aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title text-center">添加书籍其他成色副本</h4>
                </div>
                <form id="profitForm" action="{:U('Add_fb')}" method="post" enctype="multipart/form-data">
                    <div class="modal-body">
                        <div class="container-fluid">
                            <div class="row">
                                <input id="BOOK_ID" type="hidden" name="BOOK_ID" value="">

                                <div class="col-xs-12">
                                    <label>书籍副本名称</label>
                                    <input id="book_name_fb" name="book_name_fb" class="rugby-login form-control"
                                           value="">
                                </div>
                                <div class="col-xs-12">
                                    <label>书籍副本销售价格</label>
                                    <input id="XS_PRICE" name="XS_PRICE" class="rugby-login form-control" value="">
                                </div>
                                <div class="col-xs-12">
                                    <label>书籍副本成色</label>
                                    <select type="text" class="form-control" name="book_name_LEVEL">
                                        <foreach name="BOOK_LEVEL" item="v" key="k">
                                            <option value="{$v.region_name}">{$v.region_name}</option>
                                        </foreach>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit">
                            确认
                        </button>
                    </div>
                </form>
            </div>

        </div>
    </div>
    <!--副本-->

    <!--成色-->
    <div id="allayModal_1" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
         aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title text-center">书籍成色选择器</h4>
                </div>
                <!--<form action="{:U('Add')}" method="post" enctype="multipart/form-data">-->
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <input id="L_BOOK_ID" type="hidden" name="BOOK_ID" value="">

                            <div class="col-xs-12">
                                <foreach name="BOOK_LEVEL_JSD" item="v" key="k">
                                    <div class="row">
                                        <span style="text-align:left;font-size: large" class=" control-label">{$v.region_name}</span>
                                    </div>
                                    <foreach name="v.son" item="v1" key="k1">
                                        <div class="row">
                                            <input type="checkbox" name="jsd" value="{$v1.region_code}">
                                            <lable value="{$v1.region_name}">{$v1.region_name}</lable>
                                        </div>
                                    </foreach>

                                </foreach>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button onclick="Level_handling();">
                        确认
                    </button>
                </div>
                <!--</form>-->
            </div>

        </div>
    </div>
    <!--成色-->

    <!--确认成色-->
    <div id="allayModal_2" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
         aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title text-center">确认成色</h4>
                </div>
                <!--<form action="{:U('Add')}" method="post" enctype="multipart/form-data">-->
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <input id="LL_BOOK_ID" type="hidden" name="BOOK_ID" value="">

                            <div class="col-xs-12">
                                <label id="cs_data" name="cs"></label>
                                <!--<select name="cs">-->
                                <!--<option></option>-->
                                <!--</select>-->
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button onclick="qx();">
                        取消
                    </button>
                    <button onclick="qr();">
                        确认成色
                    </button>
                </div>
                <!--</form>-->
            </div>

        </div>
    </div>
    <!--确认成色-->

    <!--修改书籍排序号-->
    <div id="changesort" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
         aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title text-center">修改书籍排序号</h4>
                </div>
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row">
                            <input id="order_id" type="hidden" name="order_id" value="">

                            <div class="col-xs-12">
                                <label>序号</label>
                                <input id="sortnum" name="sortnum" class="rugby-login form-control" value="">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button onclick="updatecost()">
                        确认
                    </button>
                </div>
            </div>
        </div>
    </div>
    <!--修改书籍排序号-->


    <include file="CommonSidebar:common-script"/>
    <script src="__ROOT__/Application/Admin/Public/js/jquery.datetimepicker.js"></script>
    <!-- DataTables JavaScript -->
    <script src="__ROOT__/Application/Admin/Public/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
    <script src="__ROOT__/Application/Admin/Public/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
    <!-- Page-Level Demo Scripts - Tables - Use for reference -->


    <script type="text/javascript" src="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.js?v=3"></script>
    <link rel="stylesheet" href="__ROOT__/Application/Admin/Public/LoadPading/LoadPading.css" type="text/css"
          media="screen"/>

    <script src="__PUBLIC__/Admin/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
    <script src="__PUBLIC__/Admin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
    <script src="__PUBLIC__/Common/grid.js"></script>
    <script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
    <script>
        //排序
        $('#dataTables-example').grid({
            singleSelect: false
        });

        //修改价格
        var elem_all;
        function add(ID, elem) {
//        alert(elem.html());
            elem_all = elem;
            $("#order_id").val(ID);
            $("#sortnum").val(elem.html());
            $("#changesort").modal("show");
        }
        function updatecost() {
            var ID = $("#order_id").val();
            var sortnum = $("#sortnum").val();

            if (confirm("确认修改？")) {
                $.post("{:U('updatesort')}",
                        {ID: ID, sortnum: sortnum},
                        function (data) {
                            console.log(data);
                            if (parseInt(data) == 1) {
                                alert('修改成功');
                                elem_all.html(sortnum);
                            } else {
                                alert('修改失败');
                            }
                        });
                $("#changesort").modal("hide");
            }
        }

    </script>
    <script type="text/javascript">
        var showList = [];//显示列保存
        //显示列
        function listshow(num, elem) {
            if ($("#list" + num).is(":hidden")) {
                $("#list" + num).show();
                $(".list" + num).show();
                showList.push(num);
                elem.css('color', 'red');
            } else {
                $("#list" + num).hide();
                $(".list" + num).hide();
                showList.splice($.inArray(num, showList), 1);
                elem.css('color', '#777');
            }
        }

        <!--日期插件-->
        $('.datetimepicker_mask').datetimepicker({
            lang: 'ch',
            mask: '9999-19-39',
            format: 'Y-m-d',
            timepicker: false,    //关闭时间选项
            yearStart: 2000,     //设置最小年份
            yearEnd: 3050,        //设置最大年份
            todayButton: true,    //关闭选择今天按钮
            autoclose: true
        });
    </script>
    <script>

        //加入收书黑名单
        function AddBlackBook(ID, elem,num) {
            if (confirm("确认修改？")) {
                $.post("{:U('BlackBook/Add')}",
                        {ID: ID,num:num},
                        function (data) {
                            console.log(data);
                            if (parseInt(data) > 0) {
                                alert('修改成功');
                            } else {
                                alert('修改失败');
                            }
                            window.location.reload();
                        });
            }
        }

        //导入套装书
        function AddTzBook(BOOK_ID, $elem) {
            if (confirm("确认导入？")) {
                $.post("{:U('Book/AddTzBook')}",
                        {BOOK_ID: BOOK_ID, TZ_BOOK_LIST_ID: "{$TZ}"},
                        function (data) {
                            console.log(data);
                            if (parseInt(data) > 0) {
                                $elem.parent().parent().parent().remove();
                                alert('导入成功');
                            } else {
                                alert('导入失败');
                            }
                        });
            }
        }

        //导入包邮书籍
        function AddByBook(BOOK_ID, $elem) {
            if (confirm("确认导入？")) {
                $.post("{:U('Postage/AddBYBook')}",
                        {BOOK_ID: BOOK_ID},
                        function (data) {
                            console.log(data);
                            if (parseInt(data) > 0) {
                                $elem.parent().parent().parent().remove();
                                alert('导入成功');
                            } else {
                                alert('导入失败');
                            }
                        });
            }
        }

        //    排序
        function sort(elem) {
            var sortNAME = elem.attr("name");
            var isDESC = elem.attr("data-type");
            if (isDESC) {
                if (isDESC == 'DESC') {
                    isDESC = 'ASC'
                } else {
                    isDESC = 'DESC'
                }
            } else {
                isDESC = 'DESC'
            }
            location.href = "{:U('Index')}?sortNAME=" + sortNAME + "&isDESC=" + isDESC;
            //location.href实现客户端页面的跳转
        }
        //    显示操作
        function showcz(elem) {
            if (elem.next().next().is(":hidden")) {
                elem.next().next().show();    //如果元素为隐藏,则将它显现
            } else {
                elem.next().next().hide();     //如果元素为显现,则将其隐藏
            }
        }

        function qx() {
            $("#allayModal_2").modal("hide");
            $("#allayModal_1").modal("show");
        }
        function qr() {
            var cs = $("#cs_data").html();
            var ID = $("#LL_BOOK_ID").val();
            $.post("{:U('Level/qrhandling')}",
                    {cs: cs, ID: ID},
                    function (data) {
                        console.log(data);
                        if (data == 1) {
                            alert('修改成功');
                            $("#allayModal_2").modal("hide");
                        } else {
                            alert(data);
                        }

                    });
        }
        <!-- 成色选择器处理 -->
        function Level_handling() {
            var vals = [];
            $("input[name='jsd']:checkbox:checked").each(function (index, item) {
                vals.push($(this).val());
                $(this).attr("checked", false);
            });
//        alert(vals);
            $.post("{:U('Level/handling')}",
                    {IDS: vals},
                    function (data) {
                        console.log(data);
                        if (data) {
                            $("#allayModal_1").modal("hide");
                            $("#cs_data").html(data);
                            $("#allayModal_2").modal("show");
                        } else {

                        }

                    });
        }
        <!--成色选择器显示-->
        function selectLevel(ID, elem) {
            $("#LL_BOOK_ID").val(ID);
            $("#allayModal_1").modal("show");
        }

        function addbook_fb(ID, name, XS_PRICE) {
            $("#XS_PRICE").val(XS_PRICE);
            $("#book_name_fb").val(name);
            $("#BOOK_ID").val(ID);
            $("#allayModal").modal("show");
        }
        <!--全选择框-->
        $("#all_checkbox").click(function () {
            if ($(this).is(':checked')) {
                $("input[name='checkbox']").prop("checked", "true");
            } else {
                $("input[name='checkbox']").removeAttr("checked", false);

            }
        });
        function checkboxID() {
            var vals = [];
            $("input[name='checkbox']:checkbox:checked").each(function (index, item) {
                vals.push($(this).val());
                $(this).hide();
            });
            if (vals.length <= 0) {
                alert('请选择书籍');
                return 0;
            }
            console.log(vals);
            $.post("{:U('Basket/AddAll')}",
                    {IDS: vals},
                    function (data) {
                        console.log(data);
                        if (parseInt(data)) {
                            alert('导入书篮子成功');
                            $("input[name='checkbox']:checkbox:checked").each(function (index, item) {
                                $(this).hide();
                            });
                        } else {
                            alert('导入书篮子失败');
                        }
                    });
        }
        function updateSTOCK(ID, elem, top) {
            $.post("{:U('updateSTOCK')}",
                    {ID: ID, top: top},
                    function (data) {
                        if (parseInt(data) >= 0) {
                            if (top == 1) {
                                elem.next().html(data);
                            } else {
                                elem.prev().html(data);
                            }
                        } else {
                            alert('修改失败,库存不能小于0');
                            window.location.reload()
                        }
                    });
        }
        function del(ID, $elem) {
            if (confirm("确认删除？")) {
                $.post("{:U('delete')}",
                        {ID: ID},
                        function (data) {
                            if (parseInt(data) == 1) {
                                $elem.parent().parent().parent().remove();
                                alert('删除成功');
                            } else {
                                alert('删除失败');
                            }
                        });
            }
        }
        function GetWZ(ID, $elem) {
            $.post("{:U('GetWZ')}",
                    {ID: ID},
                    function (data) {
                        alert(data);
                    });

        }
        function RuKu(ID, $elem) {
            if (confirm("确认入库？")) {
                $.post("{:U('RuKu')}",
                        {ID: ID, SGCODE: "{$SGCODE}"},
                        function (data) {
                            if (parseInt(data) == 1) {
                                $elem.parent().parent().remove();
                                alert('入库成功');
                            } else {
                                alert('入库失败');
                            }
                        });
            }
        }
        //导入书单
        function BookList(ID, $elem) {
            if (confirm("确认导入？")) {
                $.post("{:U('BookList/AddBook')}",
                        {ID: ID, banner_id: "{$banner_id}"},
                        function (data) {
                            if (parseInt(data) == 1) {
                                $elem.parent().parent().parent().remove();
                                alert('导入成功');
                            } else {
                                alert('导入失败');
                            }
                        });
            }
        }

        //添加收书书籍
        function AddSBook(ID, $elem) {
            if (confirm("确认添加？")) {
                $.post("{:U('SBook/AddSBook')}",
                        {ID: ID},
                        function (data) {
                            if (data == 1) {
                                $elem.parent().parent().parent().remove();
                                alert('导入成功');
                            } else if (data == -1) {
                                alert('收书数据库已经存在改书籍');
                            } else {
                                alert('导入失败');
                            }
                        });
            }
        }

        //上-下架
        function updateShelves(ID, $elem) {
            var html = $elem.html();
            var str = "";
            var SXJ = 1;
            if (html == '下架中') {
                str = "确定上架该书籍吗？";
                SXJ = 1;
            } else {
                str = "确定下架该书籍吗？";
                SXJ = 0;
            }
            if (confirm(str)) {
                $.post("{:U('updateShelves')}",
                        {ID: ID, SXJ: SXJ},
                        function (data) {
                            if (parseInt(data) == 1) {
                                if (SXJ == 1) {
                                    $elem.html('上架中');
                                    $elem.removeClass();
                                    $elem.addClass('btn btn-warning btn-xs')
                                } else {
                                    $elem.html('下架中');
                                    $elem.removeClass();
                                    $elem.addClass('btn btn-danger btn-xs');
                                }
                                alert('修改成功');
                            } else {
                                alert('修改失败');
                            }
                        });
            }


        }

    </script>

</body>

</html>
